package com.example.origin.spider.demo;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.ArrayList;
import java.util.List;


public class SeleniumDemo {
    public static void main(String[] args) {

//        ChromeOptions options = new ChromeOptions();
//        WebDriver driver = new ChromeDriver(options);
//        driver.get("https://www.selenium.dev/selenium/web/web-form.html");


        WebDriver driver = null;
        System.getProperties().setProperty("webdriver.chrome.driver", "D:\\workspaces\\idea_workspaces\\origin_workspace\\origin\\origin-spider\\src\\main\\resources\\chromedriver.exe");
//        if (!ObjectUtils.isEmpty(property)) {
        List<String> list = new ArrayList<>();
        list.add("headless");
        list.add("disable-gpu");
        ChromeOptions options = new ChromeOptions();
        options.addArguments(list);
        options.addArguments("--remote-allow-origins=*");
        options.addArguments("--no-sandbox");
        driver = new ChromeDriver(options);

        driver.get("https://www.baidu.com");

        try {
            ((JavascriptExecutor) driver).executeScript("window.open('http://zxgk.court.gov.cn/waf_text_captcha');");

            //获取当前页面的url
            String url = driver.getCurrentUrl();
            System.out.println(url);
            //获取当前页面的title
            String title = driver.getTitle();
            System.out.println(title);
        } finally {
            driver.quit();
        }

    }
}
